package com.scuec.groupfive.controller;

import com.scuec.groupfive.service.AnswerStatisticsService;
import com.scuec.groupfive.vo.Result;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/api/statistics")
@CrossOrigin
public class AnswerStatisticsController {

    private final AnswerStatisticsService answerStatisticsService;

    public AnswerStatisticsController(AnswerStatisticsService answerStatisticsService) {
        this.answerStatisticsService = answerStatisticsService;
    }

    /**
     * 获取三门科目的答题比例统计
     * @return 统一响应结果
     */
    @GetMapping("/subject-ratio")
    public Result getSubjectAnswerStatistics() {
        List<Map<String, Object>> statistics = answerStatisticsService.getSubjectAnswerStatistics();
        return Result.success(statistics);
    }
}